/*
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef GRAPHIC_CORETRACE_H
#define GRAPHIC_CORETRACE_H

#include <bitset>

#include "engine_adapter/static_factory.h"
#include "utils/drawing_macros.h"

namespace OHOS {
namespace Rosen {
namespace Drawing {

enum CoreFunction {
    // libskia_canvaskit
    SKIA_DEVICE_DRAWTEXTURE_DRAW_IMAGE,
    SKIA_SKBLURMF_CREATE_PROFILE_EFFECT,
    SKIA_GRBLURUTILS_DRAW_SHAPE_WITH_MASK_FILTER,
    SKIA_GRATLASMANAGER_ADDTOATLAS,
    SKIA_GRDRAWINGMANAGER_EXECUTERENDERTASKS,
    SKIA_GRDRAWINGMANAGER_FLUSH,
    SKIA_GRDRAWINGMANAGER_FLUSHSURFACES,
    SKIA_GRDRAWOPATLAS_ACTIVATENEWPAGE,
    SKIA_GRGPU_CREATETEXTURE_1,
    SKIA_GRGPU_CREATETEXTURE_2,
    SKIA_GRGPU_CREATETEXTURECOMMON,
    SKIA_GRGPU_WRAPBACKENDTEXTURE,
    SKIA_GRGPU_WRAPRENDERABLEBACKENDTEXTURE,
    SKIA_SKGR_GRMAKECACHEDBITMAPPROXYVIEW,
    SKIA_SKGR_GRMAKEUNCACHEDBITMAPPROXYVIEW,
    SKIA_GRPROXYPROVIDER_CREATECOMPRESSEDTEXTUREPROXY,
    SKIA_GRPROXYPROVIDER_CREATEMIPPEDPROXYFROMBITMAP,
    SKIA_GRPROXYPROVIDER_CREATENONMIPPEDPROXYFROMBITMAP,
    SKIA_GRPROXYPROVIDER_CREATEPROXYFROMBITMAP,
    SKIA_GRRESOURCEALLOCATOR_ASSIGN,
    SKIA_GRRESOURCEPROVIDER_ATTACHSTENCILATTACHMENT,
    SKIA_GRRESOURCEPROVIDER_CREATEAPPROXTEXTURE,
    SKIA_GRRESOURCEPROVIDER_CREATECOMPRESSEDTEXTURE,
    SKIA_GRRESOURCEPROVIDER_CREATETEXTURE,
    SKIA_GRRESOURCEPROVIDER_WRAPRENDERABLEBACKENDTEXTURE,
    SKIA_GRSURFACEPROXY_CREATESURFACEIMPL,
    SKIA_GRSURFACEPROXY_INSTANTIATEIMPL,
    SKIA_GRSURFACEPROXYPRIV_DOLAZYINSTANTIATION,
    SKIA_GRVKGPU_ONCREATECOMPRESSEDTEXTURE_1,
    SKIA_GRVKGPU_ONCREATECOMPRESSEDTEXTURE_2,
    SKIA_GRVKGPU_ONCREATETEXTURE,
    SKIA_GRVKGPU_ONWRAPBACKENDTEXTURE,
    SKIA_GRVKGPU_ONWRAPRENDERABLEBACKENDTEXTURE,
    SKIA_GRVKIMAGE_GRVKIMAGE_1,
    SKIA_GRVKIMAGE_GRVKIMAGE_2,
    SKIA_GRVKIMAGE_MAKE,
    SKIA_GRVKIMAGE_MAKESTENCIL,
    SKIA_GRVKIMAGE_MAKETEXTURE,
    SKIA_GRVKIMAGE_MAKEWRAPPED,
    SKIA_GRVKTEXTURE_MAKENEWTEXTURE,
    SKIA_GRVKTEXTURE_MAKEWRAPPEDTEXTURE,
    SKIA_GRVKTEXTURERENDERTARGET_MAKENEWTEXTURERENDERTARGET,
    SKIA_GRVKTEXTURERENDERTARGET_MAKEWRAPPEDTEXTURERENDERTARGET,
    SKIA_SKGR_MAKE_BMP_PROXY,
    SKIA_SKGR_MAKE_DITHER_EFFECT,
    SKIA_BLURMF_MAKE_RECT_INTEGRAL_FP,
    SKIA_SKIMAGE_GPU_NEW_WRAPPED_TEXTURE_COMMON,
    SKIA_SDFBLUR_DRAWMASKSDFBLUR,
    SKIA_SKCANVAS_DRAWIMAGELATTICE,
    SKIA_SKCANVAS_DRAWIMAGENINE,
    SKIA_SKCANVAS_DRAWIMAGERECT,
    SKIA_SKCANVAS_DRAWPATH,
    SKIA_SKCANVAS_ONFLUSH,
    SKIA_ATLASTEXTOP_ONPREPAREDRAWS,
    SKIA_V1_DEVICE_DRAWPATH,
    SKIA_V1_DEVICE_DRAWSHADOW,
    SKIA_OPSTASK_ONEXECUTE,
    SKIA_SHADOWRRECTOP_MAKE,
    SKIA_SURFACEDRAWCONTEXT_DRAWFASTSHADOW,
    SKIA_SKIMAGE_MAKEFROMTEXTURE,
    SKIA_SKIMAGE_MAKETEXTUREFROMCOMPRESSED,
    SKIA_SKIMAGE_BASE_ASFRAGMENTPROCESSOR,
    SKIA_SKIMAGE_RASTER_ONASVIEW,
    SKIA_SKNWAYCANVAS_ONDRAWIMAGERECT2,
    SKIA_SKSHADOWUTILS_DRAWSHADOWSTYLE,
    SKIA_SKSURFACE_MAKEFROMBACKENDTEXTURE,
    // librender_service
    RS_SURFACE_CAPTURE_TASK_PARALLEL_DRAWCAPTUREDIMG,
    RS_SURFACE_CAPTURE_TASK_PARALLEL_GETSURFACEFROMSURFACEBUFFER,
    RS_RSBASERENDERENGINE_DRAWDISPLAYNODEWITHPARAMS,
    RS_RSBASERENDERENGINE_DRAWIMAGE,
    RS_RSBASERENDERENGINE_REQUESTFRAME,
    RS_RSCANVASDRAWINGRENDERNODEDRAWABLE_DRAWRENDERCONTENT,
    RS_RSCANVASDRAWINGRENDERNODEDRAWABLE_GPUCONTEXTRESETVK,
    RS_RSCANVASDRAWINGRENDERNODEDRAWABLE_INITSURFACEFORVK,
    RS_RSCANVASDRAWINGRENDERNODEDRAWABLE_ONDRAW,
    RS_RSCANVASDRAWINGRENDERNODEDRAWABLE_POSTPLAYBACKINCORRESPONDTHREAD,
    RS_RSCANVASDRAWINGRENDERNODEDRAWABLE_RESETSURFACEFORPLAYBACK,
    RS_RSCANVASDRAWINGRENDERNODEDRAWABLE_RESETSURFACEFORVK,
    RS_RSCANVASDRAWINGRENDERNODEDRAWABLE_REUSEBACKENDTEXTURE,
    RS_RSCANVASRENDERNODEDRAWABLE_ONCAPTURE,
    RS_RSCANVASRENDERNODEDRAWABLE_ONDRAW,
    RS_RSDISPLAYRENDERNODEDRAWABLE_ADJUSTZORDERANDDRAWSURFACENODE,
    RS_RSDISPLAYRENDERNODEDRAWABLE_DRAWHARDWAREENABLEDNODES,
    RS_RSDISPLAYRENDERNODEDRAWABLE_ONCAPTURE,
    RS_RSDISPLAYRENDERNODEDRAWABLE_ONDRAW,
    RS_RSDISPLAYRENDERNODEDRAWABLE_REQUESTFRAME,
    RS_RSDRAWFRAME_POSTANDWAIT,
    RS_RSDRAWFRAME_RENDERFRAME,
    RS_RSRENDERNODEDRAWABLE_CHECKCACHETYPEANDDRAW,
    RS_RSRENDERNODEDRAWABLE_DRAWWITHNODEGROUPCACHE,
    RS_RSRENDERNODEDRAWABLE_GENERATECACHEIFNEED,
    RS_RSRENDERNODEDRAWABLE_INITCACHEDSURFACE,
    RS_RSRENDERNODEDRAWABLE_UPDATECACHESURFACE,
    RS_RSRENDERSERVICECONNECTION_CREATEPIXELMAPFROMSURFACE,
    RS_RSSUBTHREAD_DRAWABLECACHE,
    RS_RSSUBTHREAD_DRAWABLECACHEWITHSKIMAGE,
    RS_RSSUBTHREADMANAGER_SCHEDULERENDERNODEDRAWABLE,
    RS_RSSURFACECAPTURETASKPARALLEL_CAPTURE,
    RS_RSSURFACECAPTURETASKPARALLEL_CREATESURFACESYNCCOPYTASK,
    RS_RSSURFACECAPTURETASKPARALLEL_RUN,
    RS_RSSURFACERENDERNODEDRAWABLE_CAPTURESURFACE,
    RS_RSSURFACERENDERNODEDRAWABLE_DEALWITHSELFDRAWINGNODEBUFFER,
    RS_RSSURFACERENDERNODEDRAWABLE_DEALWITHUIFIRSTCACHE,
    RS_RSSURFACERENDERNODEDRAWABLE_DRAWCACHESURFACE,
    RS_RSSURFACERENDERNODEDRAWABLE_DRAWSELFDRAWINGNODEBUFFER,
    RS_RSSURFACERENDERNODEDRAWABLE_DRAWUIFIRSTCACHE,
    RS_RSSURFACERENDERNODEDRAWABLE_DRAWUIFIRSTCACHEWITHSTARTING,
    RS_RSSURFACERENDERNODEDRAWABLE_GETCOMPLETEDIMAGE,
    RS_RSSURFACERENDERNODEDRAWABLE_INITCACHESURFACE,
    RS_RSSURFACERENDERNODEDRAWABLE_ONCAPTURE,
    RS_RSSURFACERENDERNODEDRAWABLE_ONDRAW,
    RS_RSSURFACERENDERNODEDRAWABLE_ONGENERALPROCESS,
    RS_RSSURFACERENDERNODEDRAWABLE_SUBDRAW,
    RS_RSUICAPTURETASKPARALLEL_CAPTURE,
    RS_RSUICAPTURETASKPARALLEL_CREATESURFACESYNCCOPYTASK,
    RS_RSUICAPTURETASKPARALLEL_RUN,
    RS_RSUNIRENDERENGINE_DRAWSURFACENODEWITHPARAMS,
    RS_RSUNIRENDERTHREAD_RENDER,
    RS_RSUNIRENDERUTIL_OPTIMIZEDFLUSHANDSUBMIT,
    // librender_service_base
    RS_DRAWSURFACEBUFFEROPITEM_DRAWWITHVULKAN,
    RS_NATIVEBUFFERUTILS_MAKEFROMNATIVEWINDOWBUFFER,
    RS_RSBACKGROUNDIMAGEDRAWABLE_CREATEDRAWFUNC,
    RS_RSBACKGROUNDIMAGEDRAWABLE_MAKEFROMTEXTUREFORVK,
    RS_RSCHILDRENDRAWABLE_CREATEDRAWFUNC,
    RS_RSCUSTOMMODIFIERDRAWABLE_CREATEDRAWFUNC,
    RS_RSEXTENDIMAGEOBJECT_GETRSIMAGECACHE,
    RS_RSEXTENDIMAGEOBJECT_MAKEFROMTEXTUREFORVK,
    RS_RSEXTENDIMAGEOBJECT_PREPROCESSPIXELMAP,
    RS_RSIMAGE_CANVASDRAWIMAGE,
    RS_RSIMAGE_DRAWIMAGEREPEATRECT,
    RS_RSIMAGE_DRAWIMAGEWITHROTATEDEGREE,
    RS_RSIMAGE_UPLOADGPU,
    RS_RSIMAGEBASE_DRAWIMAGE,
    RS_RSPAINTFILTERCANVASBASE_DRAWIMAGENINE,
    RS_RSPAINTFILTERCANVASBASE_DRAWIMAGERECT,
    RS_RSPAINTFILTERCANVASBASE_DRAWPATH,
    RS_RSPAINTFILTERCANVASBASE_DRAWSHADOWSTYLE,
    RS_RSPAINTFILTERCANVASBASE_FLUSH,
    RS_RSPROPERTYDRAWABLEUTILS_DRAWSHADOW,
    RS_RSPROPERTYDRAWABLEUTILS_DRAWSHADOWMASKFILTER,
    RS_RSRENDERNODEDRAWABLEADAPTER_DRAWALL,
    RS_RSRENDERNODEDRAWABLEADAPTER_DRAWBACKGROUND,
    RS_RSRENDERNODEDRAWABLEADAPTER_DRAWCHILDREN,
    RS_RSRENDERNODEDRAWABLEADAPTER_DRAWCONTENT,
    RS_RSRENDERNODEDRAWABLEADAPTER_DRAWUIFIRSTCONTENTCHILDREN,
    RS_RSRENDERNODESHADOWDRAWABLE_DRAW,
    RS_RSSHADOWDRAWABLE_CREATEDRAWFUNC,
    RS_RSSURFACEOHOSVULKAN_FLUSHFRAME,
    RS_RSSURFACEOHOSVULKAN_REQUESTFRAME,
    // lib2d_graphics
    GRAPHIC2D_DRAWCMDLIST_PLAYBACK,
    GRAPHIC2D_SKIACANVAS_DRAWIMAGENINE,
    GRAPHIC2D_SKIACANVAS_DRAWIMAGERECT,
    GRAPHIC2D_SKIACANVAS_DRAWPATH,
    GRAPHIC2D_SKIACANVAS_DRAWSHADOWSTYLE,
    GRAPHIC2D_SKIACANVASAUTOCACHE_ONDRAWIMAGERECT2,
    GRAPHIC2D_SKIAIMAGE_BUILDFROMCOMPRESSED,
    GRAPHIC2D_SKIAIMAGE_BUILDFROMTEXTURE,
    GRAPHIC2D_SKIASURFACE_FLUSH,
    GRAPHIC2D_SKIASURFACE_MAKEFROMBACKENDTEXTURE,
    // libcrete_pixelmap_surface
    PIXELMAP_CREATEPIXELMAPFROMSURFACE,
    PIXELMAP_PIXELMAPFROMSURFACE_CREATE,
    PIXELMAP_PIXELMAPFROMSURFACE_CREATEFORVK,
    PIXELMAP_PIXELMAPFROMSURFACE_CREATEDRAWINGIMAGE,
    PIXELMAP_PIXELMAPFROMSURFACE_DRAWIMAGERECTVK
};

#if defined(SK_VULKAN) && defined(SKIA_DFX_FOR_GPURESOURCE_CORETRACE)
#define RECORD_GPURESOURCE_CORETRACE_CALLER(FunctionType) \
    Drawing::StaticFactory::RecordCoreTrace(FunctionType)
#else
#define RECORD_GPURESOURCE_CORETRACE_CALLER(FunctionType)
#endif

#if defined(SK_VULKAN) && defined(SKIA_DFX_FOR_GPURESOURCE_CORETRACE)
#define RECORD_GPURESOURCE_CORETRACE_CALLER_WITHNODEID(FunctionType, NodeId) \
    Drawing::StaticFactory::RecordCoreTrace(FunctionType, NodeId)
#else
#define RECORD_GPURESOURCE_CORETRACE_CALLER_WITHNODEID(FunctionType, NodeId)
#endif

} // namespace Drawing
} // namespace Rosen
} // namespace OHOS
#endif
